package model

import (
    "github.com/hfdend/gosql"
    "git.oschina.net/hfwb/tianqi.git/tq/global"
)

type base struct {
    DB *gosql.DbMysql   `json:"-" field:"-"`
}

func (this *base) init(tableName string) {
    c := &gosql.ConfigModel{
        Host: global.Config.Mysql.Host,
        Port: global.Config.Mysql.Port,
        User: global.Config.Mysql.User,
        Password: global.Config.Mysql.Password,
        DBName: global.Config.Mysql.DBName,
        AutoCloseTime: 600,
        MaxOpenConns: 100,
        MaxIdleConns: 5,
    }
    cc := gosql.Config{
        Master: c,
        Slave: []*gosql.ConfigModel{c},
    }
    this.DB = cc.NewDbMysql()
    this.DB.SetTableName(tableName)
}
